package com.tuanzi.loan.schedule.receipt.monitor;

import java.util.HashSet;

public abstract class AbstractMonitor implements IMonitor {
    protected HashSet<ITemplate> templates = new HashSet<>();

    public AbstractMonitor() {
        initTemplates();
    }

    public abstract void initTemplates();

    public void addTemplate(ITemplate template) {
        templates.add(template);
    }

    @Override
    public void fireAlarm(Object... args) {
        for (ITemplate template : templates) {
            ISender sender = template.createSender(args);
            sender.send();
        }
    }
}
